﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="QuXianBGS.aspx.cs" Inherits="Web.Pages.YongShui.JiChuXX.QuXianBGS" Theme="Default" %>
<%@ Register Assembly="DevExpress.Web.v15.2, Version=15.2.9.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web" TagPrefix="dx" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <script src="../../../JS/AddEditCancel.js"></script>
    <script src="../../../JS/jquery.js"></script>
    <script type="text/javascript">
        function keyEnter(index) {
            var key = event.keyCode;
            if (key == 13) {
                //debugger;
                var controls = new Array();
                controls[0] = document.getElementById("ASPxPageControl1_txtQUYUBH_I");
                controls[1] = document.getElementById("ASPxPageControl1_txtQUYUMC_I");
                controls[2] = document.getElementById("ASPxPageControl1_txtMINGCHENG_I");
                controls[3] = document.getElementById("ASPxPageControl1_txtDIZHI_I");
                controls[4] = document.getElementById("ASPxPageControl1_txtYOUBIAN_I");
                controls[5] = document.getElementById("ASPxPageControl1_txtLIANXIDH_I");
                controls[6] = document.getElementById("ASPxPageControl1_txtZHUBANR_I");
                controls[7] = document.getElementById("ASPxPageControl1_txtLIANXIR_I");
                index = index + 1;
                if (index == controls.length) {
                    index = 0;
                }
                if (controls[index].disabled == false) {
                    controls[index].focus();
                }
            }
        }

        function search() {
            if (conBH.GetText() == "") {
                return;
            }
            ASPxCallback1.PerformCallback("search");
        }

        function display(op, id) {
            hdCollection.Set("ID", id);
            if (op == "add") {
                btnAdd.SetVisible(false);
                lblOperateTip.SetText("添加");
                txtQUYUBH.SetText("");
                txtQUYUBH.SetEnabled(true);
                txtQUYUMC.SetText("");
                txtQUYUMC.SetEnabled(true);
                txtMINGCHENG.SetText("");
                txtMINGCHENG.SetEnabled(true);
                txtDIZHI.SetText("");
                txtDIZHI.SetEnabled(true);
                txtYOUBIAN.SetText("");
                txtYOUBIAN.SetEnabled(true);
                txtLIANXIDH.SetText("");
                txtLIANXIDH.SetEnabled(true);
                txtZHUBANR.SetText("");
                txtZHUBANR.SetEnabled(true);
                txtLIANXIR.SetText("");
                txtLIANXIR.SetEnabled(true);
                //loadpanel1.Show();
                listCover(true, "divList");
                $("#GridViewContentTable").show();
                txtQUYUBH.Focus();
            }
            else if (op == "edit") {
                btnAdd.SetVisible(false);
                lblOperateTip.SetText("修改");
                txtQUYUBH.SetEnabled(false);
                txtQUYUMC.SetEnabled(true);
                txtMINGCHENG.SetEnabled(true);
                txtDIZHI.SetEnabled(true);
                txtYOUBIAN.SetEnabled(true);
                txtLIANXIDH.SetEnabled(true);
                txtZHUBANR.SetEnabled(true);
                txtLIANXIR.SetEnabled(true);
                //loadpanel1.Show();
                listCover(true, "divList");
                $("#GridViewContentTable").show();
                ASPxCallback1.PerformCallback("info");
                txtQUYUMC.Focus();
            }
            else {
                $("#GridViewContentTable").hide();
                btnAdd.SetVisible(true);
                //loadpanel1.Hide();
                listCover(false, "divList");
            }
        }

        function del(id) {
            hdCollection.Set("ID", id);
            if (confirm("确认删除吗？")) {
                ASPxCallback1.PerformCallback("del");
            }
            else {
                hdCollection.Set("ID", -1);
            }
        }

        function save() {
            if (txtQUYUBH.GetText() == "") {
                alert("请输入效区县编号！");
                txtQUYUBH.Focus();
                return;
            }
            if (txtQUYUMC.GetText() == "") {
                alert("请输入效区县名称！");
                txtQUYUMC.Focus();
                return;
            }
            ASPxCallback1.PerformCallback("saveValidate");
        }

        function ASPxCallback1Complete(rs) {
            var arr = rs.split('|');
            var type = arr[0];
            var state = arr[1];
            if (state != "0") {
                alert(arr[2]);
            }
            else {
                if (type == "search") {
                    gvList.SetFocusedRowIndex(arr[3]);
                    gvList.MakeRowVisible(arr[3]);
                }
                else if (type == "info") {
                    txtQUYUBH.SetText(arr[3]);
                    txtQUYUMC.SetText(arr[4]);
                    txtMINGCHENG.SetText(arr[5]);
                    txtDIZHI.SetText(arr[6]);
                    txtYOUBIAN.SetText(arr[7]);
                    txtLIANXIDH.SetText(arr[8]);
                    txtZHUBANR.SetText(arr[9]);
                    txtLIANXIR.SetText(arr[10]);
                }
                else if (type == "del") {
                    alert(arr[2]);
                    gvList.PerformCallback();
                }
                else if (type == "saveValidate") {
                    ASPxCallback1.PerformCallback("save");
                }                
                else if (type == "save") {
                    alert(arr[2]);
                    display("init", -1);
                    gvList.PerformCallback();
                }
            }
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
        <div class="tabletitle1" align="center">
            郊区县计划用水办公室
        </div>
        <div style="display: none;">
            <dx:ASPxHiddenField ID="hdCollection" ClientInstanceName="hdCollection" runat="server"></dx:ASPxHiddenField>
            <dx:ASPxCallback ID="ASPxCallback1" ClientInstanceName="ASPxCallback1" runat="server" OnCallback="ASPxCallback1_Callback" ClientSideEvents-CallbackComplete="function(s,e){ASPxCallback1Complete(e.result);}"></dx:ASPxCallback>
        </div>
         <asp:UpdatePanel runat="server" ID="updatePanel">
                                <ContentTemplate>
        <dx:ASPxPageControl ID="ASPxPageControl1" runat="server" ActiveTabIndex="0" Width="100%">
            <TabPages>
                <dx:TabPage Text="郊区县计划用水办公室">
                    <ContentCollection>
                        <dx:ContentControl runat="server" SupportsDisabledAttribute="True">
                           <div id="divList">
                                    <div align="center">
                                        <div style="width: 90%; text-align: left;">
                                            <table>
                                                <tr>
                                                    <td align="right">编号：</td>
                                                    <td>
                                                        <dx:ASPxTextBox ID="txtConBianHao" ClientInstanceName="conBH" runat="server" Width="150px" AutoPostBack="false">
                                                            <ClientSideEvents KeyPress="function(s,e){var key = event.keyCode;
                                                              if( key==13){search();}}" />
                                                        </dx:ASPxTextBox>
                                                    </td>
                                                    <td>
                                                        <dx:ASPxButton ID="btnSearch" runat="server" Text="查询" UseSubmitBehavior="false" AutoPostBack="false" ClientSideEvents-Click="function(s,e){search();}"></dx:ASPxButton>
                                                    </td>
                                                </tr>
                                            </table>
                                        </div>
                                    </div>
                                    <div align="center">
                                        <dx:ASPxGridView ID="gvList" ClientInstanceName="gvList" runat="server" EnableCallBacks="false" AutoGenerateColumns="False" KeyFieldName="ID" Theme="Aqua1" Width="90%" OnCustomCallback="gvList_CustomCallback">
                                            <Columns>
                                                <dx:GridViewDataTextColumn FieldName="S_QUYUBH" Caption="编号" Width="5%">
                                                </dx:GridViewDataTextColumn>
                                                <dx:GridViewDataTextColumn FieldName="S_QUYUMC" Caption="区县名称" Width="7%">
                                                </dx:GridViewDataTextColumn>
                                                <dx:GridViewDataTextColumn FieldName="S_MINGCHENG" Caption="公司名称" Width="15%">
                                                </dx:GridViewDataTextColumn>
                                                <dx:GridViewDataTextColumn FieldName="S_DIZHI" Caption="公司地址" Width="20%">
                                                </dx:GridViewDataTextColumn>
                                                <dx:GridViewDataTextColumn FieldName="S_YOUBIAN" Caption="邮编" Width="7%">
                                                </dx:GridViewDataTextColumn>
                                                <dx:GridViewDataTextColumn FieldName="S_LIANXIDH" Caption="联系电话" Width="7%">
                                                </dx:GridViewDataTextColumn>
                                                <dx:GridViewDataTextColumn FieldName="S_ZHUBANR" Caption="制表人" Width="7%">
                                                </dx:GridViewDataTextColumn>
                                                <dx:GridViewDataTextColumn FieldName="S_LIANXIR" Caption="负责人" Width="7%">
                                                </dx:GridViewDataTextColumn>
                                                <dx:GridViewDataTextColumn Width="4%">
                                                    <DataItemTemplate>
                                                        <a href="#" onclick="display('edit','<%#Eval("ID")%>')">修改</a>
                                                    </DataItemTemplate>
                                                </dx:GridViewDataTextColumn>
                                                <dx:GridViewDataTextColumn Width="4%">
                                                    <DataItemTemplate>
                                                        <a href="#" onclick="del('<%#Eval("ID")%>')">删除</a>
                                                    </DataItemTemplate>
                                                </dx:GridViewDataTextColumn>
                                            </Columns>
                                            <SettingsBehavior AllowFocusedRow="True"  ColumnResizeMode="Control" />
                                            <Settings VerticalScrollableHeight="210" VerticalScrollBarMode="Auto" />
                                            <ClientSideEvents Init="function(s,e){AdjustSize(350,gvList);}"  />
                                        </dx:ASPxGridView>
                                        <dx:ASPxLoadingPanel ID="ASPxLoadingPanel1" ClientInstanceName="loadpanel1" runat="server" ContainerElementID="gvList" Modal="true" Theme="Metropolis" Text=""></dx:ASPxLoadingPanel>
                                    </div>
                            </div>
                                    <div style="height: 3px;"></div>
                                    <div style="text-align: right">
                                        <hr />
                                        <dx:ASPxButton ID="btnAdd" ClientInstanceName="btnAdd" runat="server" Text="添加" AutoPostBack="false" ClientSideEvents-Click="function(s,e){display('add',-1)}" UseSubmitBehavior="false">
                                        </dx:ASPxButton>
                                    </div>
                                    <div id="GridViewContentTable"  style="display:none;">
                                        <div class="tabletitle1" align="center">
                                            <dx:ASPxLabel ID="lblOperateTip" runat="server" ClientInstanceName="lblOperateTip" Text="添加"></dx:ASPxLabel>
                                        </div>
                                        <table style="width: 65%; margin: auto;" class="TableLayoutFont">
                                            <tr>
                                                <td align="right" style="width: 20%;">编号：
                                                </td>
                                                <td style="width: 30%;">
                                                    <dx:ASPxTextBox ID="txtQUYUBH" ClientInstanceName="txtQUYUBH" runat="server" Width="100%" MaxLength="15">
                                                        <ClientSideEvents KeyUp="function(s,e){inputNum(s);keyEnter(0);}" />
                                                    </dx:ASPxTextBox>
                                                </td>
                                                <td align="right" style="width: 20%;">区县名称：
                                                </td>
                                                <td style="width: 30%;">
                                                    <dx:ASPxTextBox ID="txtQUYUMC" ClientInstanceName="txtQUYUMC" runat="server" Width="100%" MaxLength="15">
                                                        <ClientSideEvents KeyPress="function(s,e){keyEnter(1);}" />
                                                    </dx:ASPxTextBox>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td align="right">公司名称：
                                                </td>
                                                <td colspan="3">
                                                    <dx:ASPxTextBox ID="txtMINGCHENG" ClientInstanceName="txtMINGCHENG" runat="server" Width="100%" MaxLength="30">
                                                        <ClientSideEvents KeyPress="function(s,e){keyEnter(2);}" />
                                                    </dx:ASPxTextBox>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td align="right">公司地址：
                                                </td>
                                                <td colspan="3">
                                                    <dx:ASPxTextBox ID="txtDIZHI" ClientInstanceName="txtDIZHI" runat="server" Width="100%" MaxLength="50">
                                                        <ClientSideEvents KeyPress="function(s,e){keyEnter(3);}" />
                                                    </dx:ASPxTextBox>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td align="right">邮编：
                                                </td>
                                                <td>
                                                    <dx:ASPxTextBox ID="txtYOUBIAN" ClientInstanceName="txtYOUBIAN" runat="server" Width="100%" MaxLength="15">
                                                        <ClientSideEvents KeyPress="function(s,e){keyEnter(4);}" />
                                                    </dx:ASPxTextBox>
                                                </td>
                                                <td align="right">联系电话：
                                                </td>
                                                <td>
                                                    <dx:ASPxTextBox ID="txtLIANXIDH" ClientInstanceName="txtLIANXIDH" runat="server" Width="100%" MaxLength="15">
                                                        <ClientSideEvents KeyPress="function(s,e){keyEnter(5);}" />
                                                    </dx:ASPxTextBox>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td align="right">制表人：
                                                </td>
                                                <td>
                                                    <dx:ASPxTextBox ID="txtZHUBANR" ClientInstanceName="txtZHUBANR" runat="server" Width="100%" MaxLength="15">
                                                        <ClientSideEvents KeyPress="function(s,e){keyEnter(6);}" />
                                                    </dx:ASPxTextBox>
                                                </td>
                                                <td align="right">负责人：
                                                </td>
                                                <td>
                                                    <dx:ASPxTextBox ID="txtLIANXIR" ClientInstanceName="txtLIANXIR" runat="server" Width="100%" MaxLength="15">
                                                        <ClientSideEvents KeyPress="function(s,e){keyEnter(7);}" />
                                                    </dx:ASPxTextBox>
                                                </td>
                                            </tr>
                                        </table>
                                        <table id="GridViewButtonTable" runat="server" width="100%">
                                            <tr>
                                                <td style="text-align: right;">
                                                    <hr />
                                                    <dx:ASPxButton ID="ASPxButton3" runat="server" Text="保存" AutoPostBack="false" UseSubmitBehavior="false" ClientSideEvents-Click="function(s,e){save();}">
                                                    </dx:ASPxButton>
                                                    <dx:ASPxButton ID="btnCancel" runat="server" Text="放弃" AutoPostBack="false" ClientSideEvents-Click="function(s,e){display('init',-1);}" UseSubmitBehavior="false">
                                                    </dx:ASPxButton>
                                                </td>
                                            </tr>
                                        </table>
                                    </div>
                        </dx:ContentControl>
                    </ContentCollection>
                </dx:TabPage>
                <dx:TabPage Text="涉水对象接口">
                    <ContentCollection>
                        <dx:ContentControl runat="server" SupportsDisabledAttribute="True">
                            <fieldset style="padding: 2%; width: 80%; height: 120px; margin: auto;">
                                <legend>计划用水</legend>
                                <fieldset style="width: 42%; height: 80px; float: left;">
                                    <legend style="font-size: 13px;">上传数据</legend>
                                    <table style="margin: auto;">
                                        <tr>
                                            <td>年份&nbsp;
                                            </td>
                                            <td>
                                                <dx:ASPxComboBox ID="ASPxComboBox1" runat="server" ValueType="System.String">
                                                    <Items>
                                                        <dx:ListEditItem Text="2011" />
                                                        <dx:ListEditItem Text="2012" />
                                                        <dx:ListEditItem Text="2013" />
                                                        <dx:ListEditItem Text="2014" />
                                                        <dx:ListEditItem Text="2015" />
                                                        <dx:ListEditItem Text="2016" Selected="true" />
                                                    </Items>
                                                </dx:ASPxComboBox>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="right" colspan="2">
                                                <dx:ASPxButton ID="ASPxButton1" runat="server" Text="上传数据" Width="80px" UseSubmitBehavior="false"></dx:ASPxButton>
                                            </td>
                                        </tr>
                                    </table>
                                </fieldset>
                                <div style="width: 4%; float: left;">&nbsp;</div>
                                <fieldset style="width: 42%; height: 80px; float: left;">
                                    <legend style="font-size: 13px;">下载数据</legend>
                                    <table style="margin: auto;" class="tabLay">
                                        <tr>
                                            <td>&nbsp;
                                            </td>
                                            <td></td>
                                        </tr>
                                        <tr>
                                            <td align="" colspan="2">
                                                <dx:ASPxButton ID="ASPxButton2" runat="server" Text="下载数据" Width="80px" UseSubmitBehavior="false"></dx:ASPxButton>
                                            </td>
                                        </tr>
                                    </table>
                                </fieldset>
                            </fieldset>
                        </dx:ContentControl>
                    </ContentCollection>
                </dx:TabPage>
            </TabPages>
        </dx:ASPxPageControl>
                                    
                                </ContentTemplate>
                            </asp:UpdatePanel>
    </form>
</body>
</html>
